Always start transactions on an existing path.
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Fri, 9 Sep 2005 16:06:04 +0000 (16:06 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Fri, 9 Sep 2005 16:06:04 +0000 (16:06 +0000)
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/python/xen/xend/xenstore/xstransact.py

index 68e3998fb5aa2d461638ff2c40a19f72cf0b189c..0be418401a25b1d842e85b9e2a5c291503a88f84 100644 (file)
@@ -4,6 +4,7 @@
 # Public License.  See the file "COPYING" in the main directory of
 # this archive for more details.
 
+import errno
 import threading
 from xen.lowlevel import xs
 
@@ -18,9 +19,18 @@ def xshandle():
 class xstransact:
 
     def __init__(self, path):
+        self.in_transaction = False
         self.path = path.rstrip("/")
-        xshandle().transaction_start(path)
-        self.in_transaction = True
+        while True:
+            try:
+                xshandle().transaction_start(path)
+                self.in_transaction = True
+                return
+            except RuntimeError, ex:
+                if ex.args[0] == errno.ENOENT and path != "/":
+                    path = "/".join(path.split("/")[0:-1]) or "/"
+                else:
+                    raise
 
     def __del__(self):
         if self.in_transaction: